import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import path from "path"


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
	  "~": path.resolve(__dirname,"src")
    }
  },
  
  // 将http://localhost:8080 映射到前端项目 http://locahost:5173/api路径，解决了跨域问题
  server:{
	  proxy:{
		'/api': {
        target: 'http://localhost:8080/api',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
	  }
  }
})
